<?php
/*
RPHP View
@category  Core
 */
class RPHP_View
{

    protected static $_instance = null;
    public $viewsHome = "";
    public $c         = null;

    /**
     * Constructor
     *
     */
    public function __construct($c = null)
    {
        if ($c) {
            $this->c         = $c;
            $this->viewsHome = $c['_homes']['_viewsHome'];
        }
    }

    public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

    /**
     * Display
     */
    public function display($tpl, $dir = null, $ext = ".php")
    {
        if ($tpl == 4040) {
            include $tpl . $ext;
        } else {
            if (null === $dir) {
                $dir = $this->viewsHome;
            }
            if ($dir) {
                $dir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
            }
            include $dir . $tpl . $ext;
        }

    }

    public function __set($key, $value = null)
    {
        $this->$key = $value;
    }
}
